<?php
/**
 * Created by IntelliJ IDEA.
 * User: 34984
 * Date: 2017/3/26
 * Time: 17:16
 */
//参考INSERT INTO ComputerBuy VALUES (NULL, '55', '男', 'SUBURBAN', '5000-20000', '否', '是', '否', 'No');
//参数
$age       = $_GET['age'];
$sex       = $_GET['sex'];
$region       = $_GET['region'];
$income       = $_GET['income'];
$married       = $_GET['married'];
$car       = $_GET['car'];
$mortgage       = $_GET['mortgage'];
$buy       = $_GET['buy'];

//DB 配置,DO NOT USE DEFINE,$result always callback 1
$DB_HOST = '182.254.219.244:3306';
$DB_USER = 'mldb';
$DB_PASS = 'mldbtest';
$DB_DATABASENAME = 'mldb';
$DB_TABLENAME = 'ComputerBuy';
//mysql连接
$conn = mysql_connect($DB_HOST, $DB_USER, $DB_PASS) or die("connect failed" . mysql_error());
mysql_select_db($DB_DATABASENAME, $conn);

//插入操作
$sql = sprintf("INSERT INTO %s VALUES (NULL,"."'%s',"."'%s',"."'%s',"."'%s',"."'%s',"."'%s',"."'%s',"."'%s'".")", $DB_TABLENAME, $age,$sex,$region,$income,$married,$car,$mortgage,$buy);

//$sql1="INSERT INTO ComputerBuy VALUES (NULL, '55', '男', 'SUBURBAN', '5000-20000', '否', '是', '否', 'Yes');";
$result = mysql_query($sql, $conn);
mysql_close($conn);
if ($result)
    echo "t";
else
    echo "f";
?>